package com.dms.controller;


import com.dms.common.Result;
import com.dms.entity.Storedetail;
import com.dms.service.StoredetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dms
 * @since 2023-02-04
 */
@RestController
@RequestMapping("/storedetail")
public class StoredetailController {


    //注入SuserService
    @Autowired
    private StoredetailService storedetailService;

    //新增
    @PostMapping("/add")
    public Result add(@RequestBody Storedetail storedetail){
        return storedetailService.save(storedetail)? Result.suc():Result.fail();
    }
    //修改
    @PostMapping("/update")
    public Result update(@RequestBody Storedetail storedetail){
        return storedetailService.updateById(storedetail)?Result.suc():Result.fail();
    }
    @GetMapping("/findByNo")
    public Result findByNo(@RequestParam String no){
        List list= storedetailService.lambdaQuery().eq(Storedetail::getNo,no).list();
        return list.size()>0?Result.suc(list):Result.fail();
    }
}
